package com.example.spring_source_code;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

public class ApplicationContextStudy {
    public static void main(String[] args) {
        //创建Application对象，并添加beanFactory和Bean的后置处理器
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);

        for (String name : context.getBeanDefinitionNames()) {
            System.out.println(name);
        }
    }
    @Configuration
    static class Config{
        @Bean
        public Bean11 bean11(Bean2 bean2) {
            Bean11 bean11 = new Bean11();
            bean11.setBean2(bean2);
            return bean11;
        }

        @Bean
        public Bean2 bean2() {
            return new Bean2();
        }
    }

    static class Bean11 {
        private Bean2 bean2;

        public Bean2 getBean2() {
            return bean2;
        }

        public void setBean2(Bean2 bean2) {
            this.bean2 = bean2;
        }
    }
    static class Bean2{

    }
}
